package com.skstudio.reportview;

import java.util.ArrayList;

import com.skstudio.report.ReportCpu;
import com.skstudio.report.ReportCpu.DataCpu;
import com.skstudio.report.SpyData;

public class ReporterCores extends ReportViewController {

    ReportCpu mCpu = null;

    @Override
    public void setSpyData(SpyData ref) {
        super.setSpyData(ref);
        mCpu = ref.getReportCpu();
    }

    @Override
    public int getReportRows() {
        return mCpu.mDataList.size() - 1;
    }

    @Override
    public int getReportColumns() {
        if (mCpu.mDataList.size() > 0) {
            return mCpu.mDataList.get(0).size();
        }
        return 0;
    }

    @Override
    public int getEntry(int row, int col) {
        if (mCpu.mDataList.size() - 1 > row) {
            ArrayList<DataCpu> list = mCpu.mDataList.get(row + 1);
            if (list.size() > col) {
                return (int) (list.get(col).getTotalUsage());
            }
            return 0;
        }
        return 0;
    }

    @Override
    public String getReportDescription() {
        return "CPU Usage Per Core";
    }

    @Override
    public String getEntryName(int row) {
        if (mCpu.mDataList.size() - 1 > row) {
            return String.format("Core #%d load includes time spent on use mode, kernel mode, and servcing interrupts", row + 1);
        }
        return null;
    }
}
